/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package TapestryModel.impl;

import TapestryModel.ContentAttirbute;
import TapestryModel.Page;
import TapestryModel.SimpleLink;
import TapestryModel.TapestryModelPackage;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EcoreUtil;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Simple Link</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link TapestryModel.impl.SimpleLinkImpl#getPage <em>Page</em>}</li>
 *   <li>{@link TapestryModel.impl.SimpleLinkImpl#getOwner <em>Owner</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class SimpleLinkImpl extends LinkImpl implements SimpleLink {

    @Override
    public String getLinkLabel() {
        return super.getLabel();
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    protected SimpleLinkImpl() {
        super();
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    protected EClass eStaticClass() {
        return TapestryModelPackage.Literals.SIMPLE_LINK;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public Page getPage() {
        if (eContainerFeatureID != TapestryModelPackage.SIMPLE_LINK__PAGE) return null;
        return (Page)eContainer();
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public NotificationChain basicSetPage(Page newPage, NotificationChain msgs) {
        msgs = eBasicSetContainer((InternalEObject)newPage, TapestryModelPackage.SIMPLE_LINK__PAGE, msgs);
        return msgs;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setPage(Page newPage) {
        if (newPage != eInternalContainer() || (eContainerFeatureID != TapestryModelPackage.SIMPLE_LINK__PAGE && newPage != null)) {
            if (EcoreUtil.isAncestor(this, newPage))
                throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
            NotificationChain msgs = null;
            if (eInternalContainer() != null)
                msgs = eBasicRemoveFromContainer(msgs);
            if (newPage != null)
                msgs = ((InternalEObject)newPage).eInverseAdd(this, TapestryModelPackage.PAGE__LINK, Page.class, msgs);
            msgs = basicSetPage(newPage, msgs);
            if (msgs != null) msgs.dispatch();
        }
        else if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, TapestryModelPackage.SIMPLE_LINK__PAGE, newPage, newPage));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public ContentAttirbute getOwner() {
        if (eContainerFeatureID != TapestryModelPackage.SIMPLE_LINK__OWNER) return null;
        return (ContentAttirbute)eContainer();
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public NotificationChain basicSetOwner(ContentAttirbute newOwner, NotificationChain msgs) {
        msgs = eBasicSetContainer((InternalEObject)newOwner, TapestryModelPackage.SIMPLE_LINK__OWNER, msgs);
        return msgs;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setOwner(ContentAttirbute newOwner) {
        if (newOwner != eInternalContainer() || (eContainerFeatureID != TapestryModelPackage.SIMPLE_LINK__OWNER && newOwner != null)) {
            if (EcoreUtil.isAncestor(this, newOwner))
                throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
            NotificationChain msgs = null;
            if (eInternalContainer() != null)
                msgs = eBasicRemoveFromContainer(msgs);
            if (newOwner != null)
                msgs = ((InternalEObject)newOwner).eInverseAdd(this, TapestryModelPackage.CONTENT_ATTIRBUTE__LINK, ContentAttirbute.class, msgs);
            msgs = basicSetOwner(newOwner, msgs);
            if (msgs != null) msgs.dispatch();
        }
        else if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, TapestryModelPackage.SIMPLE_LINK__OWNER, newOwner, newOwner));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
        switch (featureID) {
            case TapestryModelPackage.SIMPLE_LINK__PAGE:
                if (eInternalContainer() != null)
                    msgs = eBasicRemoveFromContainer(msgs);
                return basicSetPage((Page)otherEnd, msgs);
            case TapestryModelPackage.SIMPLE_LINK__OWNER:
                if (eInternalContainer() != null)
                    msgs = eBasicRemoveFromContainer(msgs);
                return basicSetOwner((ContentAttirbute)otherEnd, msgs);
        }
        return super.eInverseAdd(otherEnd, featureID, msgs);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
        switch (featureID) {
            case TapestryModelPackage.SIMPLE_LINK__PAGE:
                return basicSetPage(null, msgs);
            case TapestryModelPackage.SIMPLE_LINK__OWNER:
                return basicSetOwner(null, msgs);
        }
        return super.eInverseRemove(otherEnd, featureID, msgs);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
        switch (eContainerFeatureID) {
            case TapestryModelPackage.SIMPLE_LINK__PAGE:
                return eInternalContainer().eInverseRemove(this, TapestryModelPackage.PAGE__LINK, Page.class, msgs);
            case TapestryModelPackage.SIMPLE_LINK__OWNER:
                return eInternalContainer().eInverseRemove(this, TapestryModelPackage.CONTENT_ATTIRBUTE__LINK, ContentAttirbute.class, msgs);
        }
        return super.eBasicRemoveFromContainerFeature(msgs);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public Object eGet(int featureID, boolean resolve, boolean coreType) {
        switch (featureID) {
            case TapestryModelPackage.SIMPLE_LINK__PAGE:
                return getPage();
            case TapestryModelPackage.SIMPLE_LINK__OWNER:
                return getOwner();
        }
        return super.eGet(featureID, resolve, coreType);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public void eSet(int featureID, Object newValue) {
        switch (featureID) {
            case TapestryModelPackage.SIMPLE_LINK__PAGE:
                setPage((Page)newValue);
                return;
            case TapestryModelPackage.SIMPLE_LINK__OWNER:
                setOwner((ContentAttirbute)newValue);
                return;
        }
        super.eSet(featureID, newValue);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public void eUnset(int featureID) {
        switch (featureID) {
            case TapestryModelPackage.SIMPLE_LINK__PAGE:
                setPage((Page)null);
                return;
            case TapestryModelPackage.SIMPLE_LINK__OWNER:
                setOwner((ContentAttirbute)null);
                return;
        }
        super.eUnset(featureID);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public boolean eIsSet(int featureID) {
        switch (featureID) {
            case TapestryModelPackage.SIMPLE_LINK__PAGE:
                return getPage() != null;
            case TapestryModelPackage.SIMPLE_LINK__OWNER:
                return getOwner() != null;
        }
        return super.eIsSet(featureID);
    }

} //SimpleLinkImpl
